﻿Imports Microsoft.VisualBasic
Imports System.Data
Imports System.Data.SqlClient


Namespace HensonOnline
    Public Class fn


        Public Shared Function CheckNull(ByVal input As String) As String
            If DBNull.Value.Equals(input) Then
                CheckNull = Nothing
            ElseIf input Is Nothing Then
                CheckNull = " "
            Else
                CheckNull = input
            End If
        End Function

        Public Shared Function CheckNull(ByVal input As Integer) As Integer
            If DBNull.Value.Equals(input) Then
                CheckNull = Nothing
            Else
                CheckNull = input
            End If
        End Function

        Public Shared Function CheckNull(ByVal input As Boolean) As Boolean
            If DBNull.Value.Equals(input) Then
                CheckNull = Nothing
            Else
                CheckNull = input
            End If
        End Function

        Public Shared Function CheckNull(ByVal input As Date) As Date
            If DBNull.Value.Equals(input) Then
                CheckNull = CDate("1/1/1900")
            Else
                CheckNull = input
            End If
        End Function

        Public Shared Function CheckNull(ByVal input As DBNull) As String
            CheckNull = Nothing
        End Function

        Public Shared Function GetUserName(ByVal userId As Integer) As String
            Dim userAdapter As New MainDbTableAdapters.UsersTableAdapter
            Dim userTable As New MainDb.UsersDataTable
            Dim userName As String = ""

            userTable = userAdapter.GetUserName(userId)
            For Each row As MainDb.UsersRow In userTable
                userName = row.FName & " " & row.LName
            Next
            Return userName
        End Function

        Public Shared Function GetImagePath(ByVal fileName As String) As String
            Dim filePath As String = "/img/imgGallery/" & fileName
            Return filePath
        End Function

    End Class
End Namespace

